package org.openzip.openzip.unpacking.view.swing;


import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Collection;
import java.util.zip.ZipEntry;

import org.openzip.openzip.gui.util.JarAdapter;
import org.openzip.openzip.gui.util.layout.SkeletonGUI;
import org.openzip.openzip.unpacking.model.IOpenZipUnpacker;
import org.openzip.openzip.unpacking.view.IUnpackerUI;


/**
 * This is an implementation of <code>IArchiverUI</code> interface.<br>
 * It provides a graphical user interface for the archiving logic. For seeing
 * how the GUI looks like, refer to the specification.
 * 
 * @author Jakub Závěrka
 */
public class UnpackGUI extends SkeletonGUI implements IUnpackerUI
{
	protected IOpenZipUnpacker logic;
	
	public UnpackGUI(){
		super();
		super.setFilePanel(new UnpackFilePanel());
		super.setAdapter(new JarAdapter());
		super.setFormLabel("OpenZIP Unpacker");
		super.setMakeArchiveButtonLabel("Extract Archive");
		super.prepareComponents();
	}
	
	/**
	 * Testing method.
	 */
	public static void main(String[] args) {
		/*try{
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch(Exception e){
			e.printStackTrace();
		}*/
		UnpackGUI gui = new UnpackGUI();
		gui.showGui(null);
	}
	
	@Override public void showGui(IOpenZipUnpacker logic){
		this.logic = logic;
		mainWindow.setVisible(true);
	}

	@Override public void showGui(IOpenZipUnpacker logic, 
				Collection<ZipEntry> files){
		throw new UnsupportedOperationException(
					"This functionality is not implemented");
		/*List<ZipEntry> list = new ArrayList<ZipEntry>();
		for(ZipEntry e : files){
			list.add(e);
		}
		Collections.sort(list, new Comparator<ZipEntry>(){
			@Override public int compare(ZipEntry o1, ZipEntry o2){
				return o1.getName().compareTo(o2.getName());
			}
		});
		for(ZipEntry e : list){
			System.out.println(e.getName());
		}*/
	}
	
	private class MakeArchiveListener implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent e) {
			//logic.unpack(filePanel.getFile(), globalSelectionModel
				//	.getSelectedFiles());
		}
	}
	
}
